#define _CRT_SECURE_NO_WARNINGS 1

# include<iostream>
# include<queue>
using namespace std;

int main()
{
    int arr[1000] = { 0 };
    int M, N;
    queue<int> q;
    cin >> M >> N;
    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        int tmp = 0;
        cin >> tmp;
        if (!arr[tmp])
        {
            if (q.size() == M)
            {
                arr[q.front()] = 0;
                q.pop();
            }
            q.push(tmp);
            ++arr[tmp];
            ++count;
        }
    }
    cout << count;
    return 0;
}

# include<iostream>
# include<string>
using namespace std;

char P1(int p1, int j)
{
    if (p1 == 1)
        return j;
    else if (p1 == 2)
        return toupper(j);
    else
        return '*';
}

int main()
{
    int p1, p2, p3;
    string s;
    cin >> p1 >> p2 >> p3;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s.at(i) == '-')
        {
            if (s.at(i - 1) == s.at(i + 1) || abs(s.at(i - 1) - s.at(i + 1)) > 26)
            {
                cout << "-";
                continue;
            }
            if (p3 == 1)
            {
                for (char j = s.at(i - 1) + 1; j < s.at(i + 1); ++j)
                {
                    char tmp = P1(p1, j);
                    for (int k = 0; k < p2; ++k)
                    {

                        cout << tmp;
                    }
                }
            }
            else
            {
                for (char j = s.at(i + 1) - 1; j > s.at(i - 1); --j)
                {
                    char tmp = P1(p1, j);
                    for (int k = 0; k < p2; ++k)
                    {
                        cout << tmp;
                    }
                }
            }
        }
        else
        {
            cout << s.at(i);
        }
    }
    return 0;
}